import 'package:flutter/material.dart';

class SliderDemo extends StatefulWidget {
  SliderDemo({Key key}) : super(key: key);

  @override
  _SliderDemoState createState() => _SliderDemoState();
}

class _SliderDemoState extends State<SliderDemo> {
  double _sliderCurrentValue = 0.0;

  void _sliderChangeState(double value){
    print('$value');
    setState(() {
      _sliderCurrentValue = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SliderDemo'),
        elevation: 0.0,
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Slider(
                value: _sliderCurrentValue,
                onChanged: _sliderChangeState,
                activeColor: Colors.amber,
                inactiveColor: Colors.amber.withOpacity(0.3),
                min: 0.0,
                max: 10.0,
                divisions: 10,
                label: '${_sliderCurrentValue.toInt()}',
              ),
            ],
          ),
          SizedBox(height:16.0),
          Text('values: $_sliderCurrentValue'),
        ],
      ),
    );
  }
}